package com.mall;

import com.alibaba.fastjson.JSON;
import com.mall.dao.UserMapper;
import com.mall.entity.User;
import com.mall.utils.UploadUtil;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.StringRedisTemplate;

import javax.annotation.Resource;
import java.io.FileNotFoundException;
import java.util.concurrent.TimeUnit;

@SpringBootTest
public class RedisText {
    @Autowired
    private UserMapper userMapper;
    @Resource
    private StringRedisTemplate stringRedisTemplate;
    @Test
    void redis() {
//        User user = userMapper.selectById(1);
//        String s = JSON.toJSONString(user);
//        stringRedisTemplate.opsForValue().set("score",s,30, TimeUnit.SECONDS);
//        String score = stringRedisTemplate.opsForValue().get("594000c4ac604606b2a6eab817096448");
//        User parse = JSON.parseObject(score,User.class);
//        System.out.println(parse.toString());
//        System.out.println(score);


        String s = null;
        try {
            s = UploadUtil.updateFile("C:\\Users\\Administrator\\Pictures\\Camera Roll\\", "wxd.jpg");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
        System.out.println(s);

    }
}
